package com.oig.sys.base.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

@Schema
@Data
public class EnumDto {

    @Schema(description = "主键id",requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,id不能为空", groups= GroupEdit.class)
    private Integer id;

    @Schema(description = "枚举类型编码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,类型编码不能为空", groups={GroupAdd.class, GroupEdit.class})
    @Length(max = 20,min = 3, message = "类型不能超过20位", groups={GroupAdd.class, GroupEdit.class})
    private String dictCode;
    @Schema(description = "枚举类型名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,枚举类型名不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String dictName;

    @Schema(description = "是否可修改 0-否 1-是 默认1，目前控制不能删除")
    @Pattern(regexp = "[0|1]", message = "是否展示只能为0或1 默认是1")
    private String modifyFlag;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "状态,04-正常 05-禁用")
    private String status;

    /**
     * 父枚举 当枚举项需要分组时，可以配一个父枚举，枚举项按父枚举的枚举值分组
     */
    @Schema(description = "当枚举项需要分组时，可以配一个父枚举，枚举项按父枚举的枚举值分组")
    private String parentDictCode;

    @Schema(description = "创建人ID")
    private Integer createUserId;
    @Schema(description = "创建人")
    private String createUserName;
    @Schema(description = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @Schema(description = "最后更新人ID")
    private Integer lastUpdateId;
    @Schema(description = "最后更新人")
    private String lastUpdateName;
    @Schema(description = "最后更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastUpdateTime;



    @Schema(description = "枚举值列表")
    @NotNull(message = "枚举值必填", groups={GroupAdd.class, GroupEdit.class})
    @Size(min = 1,message = "至少一个枚举值", groups={GroupAdd.class, GroupEdit.class})
    @Valid
    private List<EnumItemDto> enumItemList;
}
